/*
  ******************************************************************************
  * @file    main.c
  * @brief   main source File.
  ******************************************************************************
*/
#include "app.h"
#include "timer.h"
#include "adc.h"

#define UART_BAUD_RATE  115200

UART_HandleTypeDef UART2_Handle;  
extern uint8_t BatteryLowFlag;

/************************************************************************
 * function   : Uart_Init
 * Description: Uart Initiation. 
 ************************************************************************/ 
void Uart_Init(void) 
{
    UART2_Handle.Instance        = UART2;    
    UART2_Handle.Init.BaudRate   = UART_BAUD_RATE; 
    UART2_Handle.Init.WordLength = UART_WORDLENGTH_8B;
    UART2_Handle.Init.StopBits   = UART_STOPBITS_1;
    UART2_Handle.Init.Parity     = UART_PARITY_NONE;
    UART2_Handle.Init.Mode       = UART_MODE_TX_RX_DEBUG;
    UART2_Handle.Init.HwFlowCtl  = UART_HWCONTROL_NONE;
    
    HAL_UART_Init(&UART2_Handle);     
    
    // UART_DEBUG_ENABLE control printfS   
    printfS("MCU is running, HCLK=%dHz, PCLK=%dHz\n", System_Get_SystemClock(), System_Get_APBClock());    
}


int main(void)
{
    System_Init(); 
    
    Uart_Init();  

	TIM6_Init();
	LVD_Config();
	
    //Timer_Update_Test();  
    //ADC_Test();

	LCD_Config();

	LCD_YR1618A_SelfDisplay();

    while(1)
    {
		if(BatteryLowFlag)
		{
			BatteryLowFlag = 0;
			printfS("bat int\n");
		}
    }
}

